//
//  UIColor+Color_Extension.m
//  标签菜单
//
//  Created by Burn on 2019/7/25.
//  Copyright © 2019 menksoft. All rights reserved.
//

#import "UIColor+Color_Extension.h"

@implementation UIColor (Color_Extension)

- (NSArray *)getRGB{
    
    const CGFloat *component = CGColorGetComponents(self.CGColor);
    if (component == nil) {
        NSLog(@"请传入RGB值");
        return nil;
    }
    return @[@(component[0]),@(component[1]),@(component[2])];
}

+ (NSArray *)getColorDifferenceWith:(UIColor *)firstColor secondColor:(UIColor *)seconColor{
    NSArray *arrayFirst = [firstColor getRGB];
    NSArray *arraySecond = [seconColor getRGB];
    
    CGFloat r = [arrayFirst[0] floatValue] - [arraySecond[0] floatValue];
    CGFloat g = [arrayFirst[1] floatValue] - [arraySecond[1] floatValue];
    CGFloat b = [arrayFirst[2] floatValue] - [arraySecond[2] floatValue];
    return @[@(r),@(g),@(b)];
}
@end
